package com.symbio.ishenapi.doctor.controller;

import com.symbio.ishenapi.common.controller.BaseController;
import com.symbio.ishenapi.doctor.model.TmHospitalDepartment;
import io.jboot.web.controller.annotation.RequestMapping;
import vo.DepartmentMemberVO;

/**
 * 科室管理控制层
 */
@RequestMapping("/Hospitaldepartment")
public class HospitaldepartmentController extends BaseController {

    public void findTmhospitalDepartment(){
        TmHospitalDepartment tm = (TmHospitalDepartment) getReqBodyObject(TmHospitalDepartment.class);
        if (TmHospitalDepartment.dao.findById(tm.getId()) !=null){
            renderJsonError(40001);
            return;
        }
        if (tm.save()){
            renderJsonRet(tm);
        }else {
            renderError(40002);
        }
    }
    public void findTmhospital(){
        TmHospitalDepartment tm = (TmHospitalDepartment) getReqBodyObject(TmHospitalDepartment.class);
        renderJsonRet(TmHospitalDepartment.dao.findTmHospitalDepartment(tm));
    }

    //2018-12-06此表已迁移到后台
    public void findall(){
//        TmDepartmentMembers tm1 = (TmDepartmentMembers) getReqBodyObject(TmDepartmentMembers.class);
//        renderJsonRet(TmDepartmentMembers.dao.findBaseTmDepartmentMembers(tm1));
        /***
         * public List<TmDepartmentMembers> findBaseTmDepartmentMembers(BaseTmDepartmentMembers baseTmDepartmentMembers) {
         String sql =  ("SELECT tdm.* FROM tm_hospital_department thd JOIN  tm_department_members tdm ON thd.id = tdm.departmentId WHERE thd.id="+baseTmDepartmentMembers.getId());
         List<TmDepartmentMembers> find= dao.find(sql);
         return find;
         }
         */
    }

    //2018-12-06修改  作废  ---chen
    /**
     * 科室成员添加
     */
//    public void saveDepMember(){
//
//        DepartmentMemberVO departmentMemberVO = (DepartmentMemberVO)getReqBodyObject(DepartmentMemberVO.class);
//        TmHospitalDepartment tmHosDep = TmHospitalDepartment.dao.queryDepByName(departmentMemberVO);
//        if(tmHosDep==null){
//            int count = TmHospitalDepartment.dao.saveDepMember(departmentMemberVO);
//            if(count>0){
//                renderJsonError(40001,"科室成员");
//            }else{
//                renderJsonError(40002,"科室成员");
//            }
//        }else {
//            renderJsonError(40002,"科室名称已存在");
//        }
//    }
}